<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateAttendanceDailyGather extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attendance_daily_gather', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger("userId")->default(0)->comment("rmsUserID");
            $table->date("date")->nullable(true)->comment("日期");
            $table->tinyInteger("status")->default(1)->comment("考勤状态 -1 - 无考勤 0 - 异常 1 - 正常");
            $table->unsignedInteger("normalDuration")->default(0)->comment("正常时长");
            $table->unsignedInteger("missDuration")->default(0)->comment("失联时长");
            $table->unsignedInteger("traceDistance")->default(0)->comment("轨迹距离");

            $table->unsignedTinyInteger("checkStatus")->default(0)->comment("当日考勤核验状态 0 - 待核验 1 - 已核验");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '考勤每日记录表';
            $table->unique(["userId", "date"], "idx_userId_date");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attendance_daily_gather');
    }
}
